home *** CD-ROM | disk | FTP | other *** search
/ CICA 1993 April / CICA MS Windows - April 1993.iso / unzipped / programr / bcpp / cmmdlg / usrwin_.pas < prev   
Pascal/Delphi Source File  |  1992-09-07  |  5KB  |  276 lines

  1. {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
  2. {   \\\                                    }
  3. {  -(j)-                                   }
  4. {    /juanca                               }
  5. {    ~                                     }
  6. {$D ⌐ ACASA 1989-1992, All rights reserved }
  7. {%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%}
  8.  
  9. { tUsrWin object, easier to hanlde descendant of tWindow,
  10.   it takes a tPort for painting, instead of a Device Context
  11.   and has a PrintPage method that is called from a tPrinter object
  12.   }
  13.  
  14. UNIT USRWIN_;
  15. {$C MOVEABLE DEMANDLOAD DISCARDABLE}
  16. INTERFACE
  17.   USES
  18.     WINTYPES,
  19.     WOBJECTS,
  20.     COMMDLG,
  21.     PORT_;
  22.  
  23.   TYPE
  24.     Super   = TWindow;
  25.     PUsrWin = ^TUsrWin;
  26.     TUsrWin = OBJECT ( Super )
  27.  
  28.       FUNCTION
  29.         getPort:PPort;
  30.           virtual;
  31.  
  32.       FUNCTION
  33.       extraText :pChar;
  34.         virtual;
  35.  
  36.       PROCEDURE
  37.         setText(s:pChar);
  38.           virtual;
  39.       PROCEDURE
  40.       paint(paintDC:HDC; VAR paintInfo:TPaintStruct);
  41.         virtual;
  42.       PROCEDURE
  43.       upaint(dc:pPort; bounds:tRect; erased:Boolean);
  44.         virtual;
  45.  
  46.       PROCEDURE
  47.       printPage(dc :pPort; page: Word; size: tPoint; var bounds: tRect; pflags: Word);
  48.         virtual;
  49.  
  50.       PROCEDURE
  51.       getPrintRange(var fromPage, toPage :Word);
  52.         virtual;
  53.  
  54.       FUNCTION
  55.       printFlags :Longint;
  56.         virtual;
  57.  
  58.       PROCEDURE
  59.         repaintAll(erase:Boolean);
  60.       PROCEDURE
  61.         repaint(Box:tRect;erase:Boolean);
  62.  
  63.       PROCEDURE
  64.       setRepaintFlag(onOff :Boolean);
  65.  
  66.       PROCEDURE
  67.         update;
  68.  
  69.       PROCEDURE
  70.       move(bounds :tRect; redraw:Boolean);
  71.  
  72.       FUNCTION
  73.         post(msg, wparam:Word; lparam:Longint):Boolean;
  74.       FUNCTION
  75.         send(msg, wparam:Word; lparam:Longint):Longint;
  76.  
  77.       PROCEDURE
  78.         getClientRect(var b:tRect);
  79.  
  80.       PROCEDURE
  81.         alert(msg:pChar);
  82.  
  83.     END;
  84.  
  85.  
  86. {@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@}
  87. IMPLEMENTATION
  88.   USES
  89.     WINPROCS,
  90.     STRINGS;
  91.  
  92.   {}
  93.   {}
  94.   FUNCTION
  95.   TUsrWin.
  96.   getPort:PPort;
  97.     begin
  98.       getPort := new(PPort, initGet(@self))
  99.     end;
  100.  
  101.   FUNCTION
  102.   TUsrWin.
  103.   {}
  104.   extraText :pChar;
  105.     begin
  106.       extraText := ''
  107.     end;
  108.  
  109.  
  110.   PROCEDURE
  111.   TUsrWin.
  112.   {}
  113.   setText(s:pChar);
  114.     begin
  115.        setWindowText(hWindow, s)
  116.     end;
  117.  
  118.   PROCEDURE
  119.   tUsrWin.
  120.   {}
  121.   paint(paintDC:HDC; VAR paintInfo:TPaintStruct);
  122.     var
  123.       Box       :tRect;
  124.       dc        :PPort;
  125.       oldCursor :THandle;
  126.     begin
  127.       oldCursor := setCursor(loadCursor(null, idc_Wait));
  128.       dc := getPort;
  129.       dc^.set_context(paintDC);
  130.       with paintInfo
  131.       do
  132.         upaint(dc, rcPaint, fErase);
  133.       dc^.free;
  134.       setCursor(oldCursor);
  135.     end;
  136.  
  137.   PROCEDURE
  138.   tUsrWin.
  139.   {}
  140.   upaint(dc:PPort; bounds:tRect; erased:Boolean);
  141.     begin
  142.     end;
  143.  
  144.   PROCEDURE
  145.   tUsrWin.
  146.   {}
  147.   printPage(dc :pPort; page: Word; size: tPoint; var bounds: tRect; pflags: Word);
  148.     begin
  149.       upaint(dc, bounds, TRUE)
  150.     end;
  151.  
  152.   PROCEDURE
  153.   TUsrWin.
  154.   {}
  155.   getPrintRange(var fromPage, toPage :Word);
  156.     begin
  157.       fromPage := 1;
  158.       toPage   := 1;
  159.     end;
  160.  
  161.   FUNCTION
  162.   TUsrWin.
  163.   {}
  164.   printFlags :Longint;
  165.     begin
  166.        printFlags :=    pd_ReturnDC or
  167.                         pd_UseDevModeCopies or
  168.                         pd_NoSelection or
  169.                         pd_NoPageNums or
  170.                         pd_NoWarning
  171.     end;
  172.  
  173.  
  174.   PROCEDURE
  175.   TUsrWin.
  176.   {}
  177.   repaintAll(erase:Boolean);
  178.     begin
  179.       invalidateRect(hwindow, nil, erase)
  180.     end;
  181.  
  182.   PROCEDURE
  183.   TUsrWin.
  184.   {}
  185.   repaint(box:tRect; erase:Boolean);
  186.     var
  187.       r  :TRect;
  188.       dc :PPort;
  189.     begin
  190.       dc := getPort;
  191.       dc^.lp2dp(box, 2);
  192.       with box
  193.       do
  194.         setRect(r, left, top, right, bottom);
  195.       invalidateRect(hwindow, @r, erase);
  196.       dc^.free
  197.     end;
  198.  
  199.  
  200.   PROCEDURE
  201.   TUsrWin.
  202.   {}
  203.   setRepaintFlag(onOff :Boolean);
  204.     begin
  205.       send(wm_SetRedraw, Word(onOff), null)
  206.     end;
  207.  
  208.  
  209.   PROCEDURE
  210.   TUsrWin.
  211.   {}
  212.   getClientRect(var b:tRect);
  213.     var
  214.       r :TRect;
  215.     begin
  216.       WINPROCS.getClientRect(hwindow, r);
  217.     end;
  218.  
  219.  
  220.   PROCEDURE
  221.     {}
  222.   alert(win:PWindowsObject; msg:pChar);
  223.     var
  224.       flags:Word;
  225.     begin
  226.       flags :=  mb_Ok or mb_IconExclamation;
  227.       messageBeep(flags);
  228.       messageBox(win^.hwindow, msg, Application^.name, flags);
  229.     end;
  230.  
  231.   PROCEDURE
  232.   TUsrWin.
  233.     {}
  234.   alert(msg :pChar);
  235.     var
  236.       f:Word;
  237.     begin
  238.       USRWIN_.alert(@self, msg)
  239.     end;
  240.  
  241.   PROCEDURE
  242.   TUsrWin.
  243.    {}
  244.   update;
  245.     begin
  246.       updateWindow(hwindow)
  247.     end;
  248.  
  249.   PROCEDURE
  250.   TUsrWin.
  251.    {}
  252.   move(bounds :tRect; redraw:Boolean);
  253.     begin
  254.       with bounds
  255.       do
  256.         moveWindow(hwindow, left, top, left-right, bottom-top, redraw)
  257.     end;
  258.  
  259.   FUNCTION
  260.   TUsrWin.
  261.     post(msg, wparam:Word; lparam:Longint):Boolean;
  262.       begin
  263.         post := 0 <> Word(postMessage(hwindow, msg, wparam, lparam))
  264.       end;
  265.  
  266.   FUNCTION
  267.   TUsrWin.
  268.     send(msg, wparam:Word; lparam:Longint):Longint;
  269.       begin
  270.         msg := sendMessage(hwindow, msg, wparam, lparam)
  271.       end;
  272.  
  273.  
  274.  
  275. END.
  276.